package com.semp.jadoma.admin.bm.dao;

import org.hibernate.Query;
import org.hibernate.Session;

import com.semp.jadoma.admin.bm.model.Admin;
import com.semp.jadoma.admin.utils.HibernateUtil;

public class AdminDao {
	
	private final static String FIND_BY_LOGIN = "from Admin a where a.login = :login";

	public final static Admin findByLogin(String login) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		session.beginTransaction();
		Query query = session.createQuery(FIND_BY_LOGIN);
		query.setParameter("login", login);
		Admin toReturn = (Admin) query.uniqueResult();
		session.close();
		return toReturn;
	}
	
}
